#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int MOD = 1e9 + 7;
stack<int> one_stack;
stack<int> zero_stack;

void cal(int a_one, int b_one, int a_zero, int b_zero, char op, int &s_one,
         int &s_zero) {

  if (op == '&') {
    s_one = a_one * b_one;
    s_zero = a_zero * b_zero + a_one * b_zero + a_zero * b_one;

  } else if (op == '|') {
    s_one = a_one * b_one + a_one * b_zero + a_zero * b_one;
    s_zero = a_zero * b_zero;
  } else if (op == '^') {
    s_one = a_one * b_zero + a_zero * b_one;
    s_zero = a_one * b_one + a_zero * b_zero;
  }
  s_one %= MOD;
  s_zero %= MOD;
}
int main() {
  string s;
  cin >> s;
  int len = s.size();

  for (int i = 0; i < len; i++) {

    switch (s[i]) {
    case '0':
      zero_stack.push(1);
      one_stack.push(0);
      break;
    case '1':
      zero_stack.push(0);
      one_stack.push(1);
      break;
    case '?':
      zero_stack.push(1);
      one_stack.push(1);
      break;
    default:
      int one_b = one_stack.top();
      one_stack.pop();
      int one_a = one_stack.top();
      one_stack.pop();

      int zero_b = zero_stack.top();
      zero_stack.pop();
      int zero_a = zero_stack.top();
      zero_stack.pop();
      int x, y;
      cal(one_a, one_b, zero_a, zero_b, s[i], x, y);

      one_stack.push(x);
      zero_stack.push(y);

      break;
    }
  }
  cout << zero_stack.top() << endl;
  return 0;
}